package group

import (
	"context"
	"fmt"
	"os"
	model "service/model/hr"
	mCache "service/model/hr_cache"
	"service/model/mod"
	"strconv"
	"time"

	gpb "gitee.com/cloudapex/protos/hr/pb"
	gpa "gitee.com/cloudapex/protos/hr_cache/pb"

	"gitee.com/cloudapex/ulern/htp"
	"gitee.com/cloudapex/ulern/util"
	"github.com/360EntSecGroup-Skylar/excelize/v2"
	"github.com/gin-gonic/gin"
)

/*
 * 描述: 添加组织架构
 * 路由: group/addGroup
 * 方法: POST
 *********************************************************************/
type GroupAdd struct {
	CId      int64  `form:"cid" json:"cid"`                      //公司ID
	Leve     int64  `form:"leve" json:"leve"`                    //当前层级
	Superior int64  `form:"superior" json:"superior"`            //上级ID
	Name     string `form:"name" json:"name" binding:"required"` //组织名称
	//Shows      uint64 `form:"showId" json:"showId"`                //数据可见区间
	Order      int64 `form:"orderNum" json:"orderNum"`     //上移下移
	WxFraOrder int64 `form:"wxFraOrder" json:"wxFraOrder"` //微信order
	WxFraId    int64 `form:"wxFraId" json:"wxFraId"`       //微信id
}

func (this *GroupAdd) Handle(c *gin.Context, ctx context.Context) htp.Response {
	//添加企业微信架构,成功之后入库
	var wFra model.Department
	wFra.Name = this.Name
	wFra.ParentId = this.WxFraId
	res, err := wFra.AddFram()

	if err != nil {
		return htp.RespModelErr("", err)
	}
	// 入库
	rsp, err := model.Framework.AddFramework(ctx, &gpb.FrameworkReq{
		CId:      this.CId,
		Leve:     this.Leve,
		Superior: this.Superior,
		Name:     this.Name,
		//Shows:      this.Shows,
		Order:      this.Order,
		WxFraOrder: res.Order,
		WxFraId:    res.Id,
	}) // rs = null
	if err != nil {
		return htp.RespModelErr("", err)
	}
	// 缓存
	if _, err := mCache.FrameWorkCache.AddFramework(ctx, &gpa.FrameworkCacheReq{
		Id:       rsp.Id,
		CId:      this.CId,
		Name:     this.Name,
		Leve:     this.Leve,
		Superior: this.Superior,
		Shows:    rsp.Shows,
		Order:    this.Order,
	}); err != nil {
		util.Error(err.Error())
	}
	return htp.RespOK("", &struct {
		GroupId    int64 `json:"groupId"`
		WxFraOrder int64 `form:"wxFraOrder" json:"wxFraOrder"` //微信order
		WxFraId    int64 `form:"wxFraId" json:"wxFraId"`       //微信id
	}{rsp.Id, res.Order, res.Id})
}

/*
 * 描述: 删除组织架构
 * 路由: group/delGroup
 * 方法: POST
 *********************************************************************/
type GroupDel struct {
	Id       int64 `form:"groupId" json:"groupId"`   //组织ID
	Superior int64 `form:"superior" json:"superior"` //上级ID
	WxFraId  int64 `form:"wxFraId" json:"wxFraId"`   //微信id
}

func (this *GroupDel) Handle(c *gin.Context, ctx context.Context) htp.Response {
	//删除企业微信架构,成功之后入库
	var wFra model.Department
	wFra.Id = this.WxFraId
	_, err := wFra.DelFram()

	if err != nil {
		return htp.RespModelErr("", err)
	}
	rsp, err := model.Framework.DelFramework(ctx, &gpb.FrameworkReq{
		Id: this.Id,
	}) // rs = null
	if err != nil {
		return htp.RespModelErr("", err)
	}
	return htp.RespOK("", rsp)
}

/*
 * 描述: 获取当前层级Id的子架构
 * 路由: group/getSonGroup
 * 方法: POST
 *********************************************************************/
type GroupSon struct {
	Id       int64 `form:"groupId" json:"groupId"`   //组织ID
	Superior int64 `form:"superior" json:"superior"` //上级ID
	WxFraId  int64 `form:"wxFraId" json:"wxFraId"`   //微信id
}

func (this *GroupSon) Handle(c *gin.Context, ctx context.Context) htp.Response {
	type frameworkReq struct {
		Id         int64  `json:"id"`         //-- 架构id
		CId        int64  `json:"cId"`        //-- 公司ID
		Leve       int64  `json:"leve"`       //      -- 当前层级
		Superior   int64  `json:"superior"`   //   -- 上级ID
		Name       string `json:"name"`       //    -- 名称
		Shows      string `json:"showstr"`    //    -- 数据可见区间
		Order      int64  `json:"order"`      //当前层级下的排序
		Action     int64  `json:"action"`     //(0,1)代表上移下移
		WxFraOrder int64  `json:"wxFraOrder"` //微信排序
		WxFraId    int64  `json:"wxFraId"`    //微信ID
	}
	type result struct {
		FrameworkReqs []frameworkReq `json:"frameworkReqs"`
	}

	rsp, err := model.Framework.GetFrameList(ctx, &gpb.FrameworkReq{
		Superior: this.Id,
	}) // rs = null
	if err != nil {
		return htp.RespModelErr("", err)
	}

	ret := result{}
	util.Convert(&ret, rsp)
	for n, it := range rsp.FrameworkReqs {
		ret.FrameworkReqs[n].Shows = fmt.Sprintf("%d", it.Shows)
	}
	return htp.RespOK("", &ret)
}

/*
 * 描述: 查询当前架构信息
 * 路由: group/getGroup
 * 方法: POST
 *********************************************************************/
type GroupGet struct {
	Id       int64 `form:"groupId" json:"groupId"`   //组织ID
	Superior int64 `form:"superior" json:"superior"` //上级ID
	WxFraId  int64 `form:"wxFraId" json:"wxFraId"`   //微信id
}

func (this *GroupGet) Handle(c *gin.Context, ctx context.Context) htp.Response {
	rsp, err := model.Framework.GetFramework(ctx, &gpb.FrameworkReq{
		Id: this.Id,
	}) // rs = null
	if err != nil {
		return htp.RespModelErr("", err)
	}
	return htp.RespOK("", rsp)
}

/*
 * 描述: 上下移动
 * 路由: group/moveGroup
 * 方法: POST
 *********************************************************************/
type MoveGroup struct {
	Id1        int64 `form:"idOne" json:"idOne" binding:"required"`               //id1
	Id2        int64 `form:"idTwo" json:"idTwo" binding:"required"`               //id2
	WxOrderId1 int64 `form:"wxOrderIdOne" json:"wxOrderIdOne" binding:"required"` //id2
	WxOrderId2 int64 `form:"wxOrderIdTwo" json:"wxOrderIdTwo" binding:"required"` //id2
	WxFraId1   int64 `form:"wxFraIdOne" json:"wxFraIdOne" binding:"required"`     //微信id1
	WxFraId2   int64 `form:"wxFraIdTwo" json:"wxFraIdTwo" binding:"required"`     //微信id2
}

func (this *MoveGroup) Handle(c *gin.Context, ctx context.Context) htp.Response {
	//更新企业微信架构
	var wFra model.Department
	wFra.Id = this.WxFraId1
	wFra.Order = this.WxOrderId2
	err := wFra.UpdateFramOrder()

	if err != nil {
		return htp.RespModelErr("", err)
	}

	var wFra2 model.Department
	wFra2.Id = this.WxFraId2
	wFra2.Order = this.WxOrderId1

	err2 := wFra.UpdateFramOrder()
	if err2 != nil {
		return htp.RespModelErr("", err)
	}

	rsp, err := model.Framework.OrderFramework(ctx, &gpb.SwitchReq{
		Id1: this.Id1,
		Id2: this.Id2,
	}) // rs = null
	if err != nil {
		return htp.RespModelErr("", err)
	}
	return htp.RespOK("", rsp)
}

/*
 * 描述: 编辑组织架构名称
 * 路由: group/setGroup
 * 方法: POST
 *********************************************************************/
type GroupSet struct {
	GId     int64  `form:"gId" json:"gId" binding:"required"`     //组织ID
	Name    string `form:"gName" json:"gName" binding:"required"` //组织名称
	WxFraId int64  `form:"wxFraId" json:"wxFraId"`                //微信id
}

func (this *GroupSet) Handle(c *gin.Context, ctx context.Context) htp.Response {
	//更新企业微信架构
	var wFra model.Department
	wFra.Id = this.WxFraId
	wFra.Name = this.Name
	err := wFra.UpdateFram()

	if err != nil {
		return htp.RespModelErr("", err)
	}

	rsp, err := model.Framework.EditFramework(ctx, &gpb.FrameworkReq{
		Id:   this.GId,
		Name: this.Name,
	}) // rs = null
	if err != nil {
		return htp.RespModelErr("", err)
	}
	if _, err := mCache.FrameWorkCache.EditFramework(ctx, &gpa.FrameworkCacheReq{
		Id:   rsp.Id,
		Name: this.Name,
	}); err != nil {
		util.Error(err.Error())
	}
	return htp.RespOK("", rsp)
}

/*
 * 描述: 切换组织架构名
 * 路由: user/changGroup
 * 方法: POST
 *********************************************************************/
type ChangeGroup struct {
	CId       int64   `form:"cId" json:"cId"`                              //组织ID
	UserId    int64   `form:"userId" json:"userId"`                        //用户ID
	NewFraIds []int64 `form:"newFraId" json:"newFraId" binding:"required"` //组织ID
	RoleId    int64   `form:"roleId" json:"roleId" binding:"omitempty"`    //角色ID
	WId       int64   `form:"wId" json:"wId" binding:"required"`           //岗位ID
}

func (this *ChangeGroup) Handle(c *gin.Context, ctx context.Context) htp.Response {
	jwtUser := mod.CurrUser(c)
	rsp, err := model.Framework.ChangeUserFrame(ctx, &gpb.StaffEditReq{
		CId:       this.CId,
		Id:        this.UserId,
		NewFraIds: this.NewFraIds,
		RoleId:    this.RoleId,
		WId:       this.WId,
	})
	if err != nil {
		return htp.RespModelErr("", err)
	}
	_, err = model.Framework.AddChangeFramRole(ctx, &gpb.ChangeFraRoleReq{
		CId:      this.CId,
		UId:      this.UserId,
		OperId:   jwtUser.UId,
		FrameIds: this.NewFraIds,
		RoleId:   this.RoleId,
		WId:      this.WId,
	})
	if err != nil {
		return htp.RespModelErr("", err)
	}
	return htp.RespOK("", rsp)
}

/*
 * 描述: 查询员工列表
 * 路由: user/changeGroupLog
 * 方法: GET
 *********************************************************************/
type ChangeGroupLog struct {
	UserId int64 `form:"userId" json:"userId" binding:"required"` //用户ID
	Page   int64 `form:"page" json:"page" binding:"required"`     //页码
	Count  int64 `form:"count" json:"count" binding:"required"`   //角色ID
}

func (this *ChangeGroupLog) Handle(c *gin.Context, ctx context.Context) htp.Response {
	jwtUser := mod.CurrUser(c)
	roleList := new(gpb.ChangeFraRoleReq)
	roleList.UId = this.UserId
	roleList.CId = jwtUser.CId
	rsp, err := model.Framework.ChangeFramRoleList(ctx, &gpb.ChangeListReq{
		ChangeReq: roleList,
		Page:      this.Page,
		Count:     this.Count,
	})
	if err != nil {
		return htp.RespModelErr("", err)
	}
	//获取所有组织架构该企业下
	var vName string

	var userIds []int64
	if rsp != nil && len(rsp.ChangeList) > 0 {
		//查询缓存里的组织架构信息
		wRes, err := mCache.FrameWorkCache.FrameCacheReqList(ctx, &gpa.FrameworkCacheReq{
			CId: jwtUser.CId,
		})
		if err != nil {
			return htp.RespModelErr("", err)
		}
		for _, v := range rsp.ChangeList {
			userIds = append(userIds, v.UId)
		}
		fmt.Println(userIds)
		/*//查询 每个人的 多组织架构
		f := &model.StaffShowsframe{
			gpb.StaffShowsReq{
				Hids: userIds,
			},
		}
		res, err := f.GetStaffShowsframe(ctx)*/
		if err != nil {
			return htp.RespModelErr("", err)
		}
		for _, v := range rsp.ChangeList {
			fmt.Println("ids-------", v.FrameIds)
			vName = ""
			if len(v.FrameIds) > 0 {
				for _, showid := range v.FrameIds {
					_, has := wRes.FrameMap[showid]
					if has {
						vName += mCache.FrameWorkCache.GetFrameName(showid, jwtUser.CId, wRes) + "，"
					}
				}
			}
			/*for _, v1 := range res.StaffShows {
				fmt.Println(res.StaffShows)
				if v.UId == v1.HId {
					fmt.Println(v1.ShowId)
					_, has := wRes.FrameMap[v1.ShowId]
					if has {
						vName += w.GetFrameName(v1.ShowId, jwtUser.CId, wRes) + "，"
					}
				}
			}*/
			v.FrameName = vName
		}
	}

	return htp.RespOK("", rsp)
}

/*
 * 描述: 查询员工列表
 * 路由: user/exportStaff
 * 方法: GET
 *********************************************************************/
type StaffList struct {
	Phone      string `form:"phone" json:"phone"`           //手机号
	City       string `form:"city" json:"city"`             //工作城市
	WorkId     int64  `form:"workId" json:"workId"`         //员工ID
	NumberId   string `form:"numberId" json:"numberId"`     //身份证号
	WorkName   string `form:"tWorkName" json:"tWorkName"`   //招聘人
	Name       string `form:"userName" json:"userName"`     //姓名
	WId        int64  `form:"wId" json:"wId"`               //岗位ID
	RoleId     int64  `form:"roleId" json:"roleId"`         //角色ID
	ShowId     int64  `form:"showId" json:"showId"`         //组织架构ID
	State      int64  `form:"inState" json:"inState"`       //在职状态
	RegState   int64  `form:"resState" json:"resState"`     //登记状态
	InAt       int64  `form:"inAt" json:"inAt"`             //入职时间
	FirstState int64  `form:"firstState" json:"firstState"` //是否首次入职
	PinUid     int64  `form:"pinUserId" json:"pinUserId"`   //招聘人ID.
	Tag        int64  `form:"tagId" json:"tagId"`           //离职标签
	TimeReq    []struct {
		Tag   int64 `form:"tag" json:"tag"`         //1入职时间 2社保缴费时间 3合同时间 4 离职时间 5转正时间
		Start int64 `form:"startAt" json:"startAt"` //开始时间
		End   int64 `form:"endAt" json:"endAt"`     //结束时间
	} `form:"timeRep" json:"timeRep"`
	Page  int64 `form:"page" json:"page"`   //页码
	Count int64 `form:"count" json:"count"` //总数
}
type StaffECode int // 错误码
const (
	Staff_ParameterError StaffECode = iota + 1
	StaffCode_ParameterError
)

func (this *StaffList) Handle(c *gin.Context, ctx context.Context) htp.Response {
	//定义 导出的表头
	xlsxNews := excelize.NewFile()

	jwtUser := mod.CurrUser(c)
	if jwtUser.CId < 0 {
		return htp.RespErr(int(StaffCode_ParameterError), "参数错误", nil)
	}
	fmt.Println("对象", this.TimeReq)
	timeReq := make([]*gpb.TimeReq, 0)
	if len(this.TimeReq) > 0 {
		for _, v := range this.TimeReq {
			timePara := new(gpb.TimeReq)
			timePara.Tag = v.Tag
			timePara.Start = v.Start
			timePara.End = v.End
			timeReq = append(timeReq, timePara)
		}
	}
	fmt.Println("组合", timeReq)

	rsp, err := model.StaffServer.GetDetailList(ctx, &gpb.HrDetailReq{
		Count: this.Count,
		Page:  this.Page,
		BaseReq: &gpb.HrBaseReq{
			CId:        jwtUser.CId,
			Phone:      this.Phone,
			WorkId:     this.WorkId,
			TWorkName:  this.WorkName,
			NumberId:   this.NumberId,
			NumberName: this.Name,
			City:       this.City,
			WId:        this.WId,
			RoleId:     this.RoleId,
			ShowId:     this.ShowId,
			State:      this.RegState,
		},
		InOutReq: &gpb.InOutReq{
			State:    this.State,
			InAt:     this.InAt,
			Turnover: this.FirstState,
			PinUid:   this.PinUid,
			TimeReq:  timeReq,
			Tag:      this.Tag,
		},
	})
	//去离职标签
	e, err := model.StaffServer.GetQuitTag(ctx, &gpb.QuitTagReq{
		CId: jwtUser.CId,
	})
	if err != nil {
		return htp.RespModelErr("", err)
	}
	if rsp != nil && len(rsp.ModelDetails) > 0 {
		for _, v := range rsp.ModelDetails {
			for _, ve := range e.QuitTags {
				if v.StaffInOut.Tag == ve.Id {
					v.StaffInOut.TagName = ve.Name
				}
			}
		}
	}
	fmt.Println(e)
	if err != nil {
		return htp.RespErr(int(StaffCode_ParameterError), "参数错误", nil)
	}
	xlsxNews.SetSheetRow("Sheet1", "A1", &[]interface{}{
		"员工号", "姓名", "身份证姓名", "手机号", "组织架构", "角色", "岗位", "员工状态", "在职状态", "入职时间", "离职时间",
		"合同是否签署", "合同签署类型", "合同签署时间", "是否已交社保", "缴保城市", "社保期缴日期", "招聘人", "性别",
		"出生日期", "户籍类型", "籍贯地址", "现住地址", "邮箱", "婚姻状况", "身份证号", "紧急联系人", "紧急联系人电话",
		"开户银行", "支行信息", "银行卡号", "学历", "毕业学校", "入学时间", "专业", "工作地点", "介绍人", "是否首次入职", "转正时间", "毕业时间", "备注",
	})
	var filepath string
	//因为index是从0开始，第一行被字段占用，从第二行开始写入整行数据
	lint := 2
	if len(rsp.ModelDetails) > 0 {
		for _, v := range rsp.ModelDetails {
			//员工状态
			employeeState, sexTitle := EmployeeStatus(v.StaffInOut.State, v.BaseRes.Sex)
			//在职状态
			userInfoState := EmployeeInfoStatus(v.StaffInOut.State)
			fmt.Println(sexTitle)
			//合同是否签署  签署类型
			isCont, typeContra := ContraStatus(v.StaffContra.State, v.StaffContra.ContType)
			fmt.Println(typeContra)
			//是否已交社保
			isSocial := SocialStatus(v.StaffInsura.State)
			//户籍类型 婚姻状况
			regAddress, Marriage := RegAdderss(v.BaseRes.HujiType, v.BaseRes.Marriage)
			//获取员工开户银行
			rspBankInfo, _ := model.StaffServer.GetBanks(ctx, &gpb.StaffBank{
				Hid: v.BaseRes.Id,
			})
			//开户银行类型
			var bankStatus string
			var bankInfo string
			var cardNumber string
			if rspBankInfo != nil && len(rspBankInfo.BankInfos) > 0 {
				bankStatus = BankStatus(rspBankInfo.BankInfos[0].BankType)
				bankInfo = rspBankInfo.BankInfos[0].BankInfo
				cardNumber = rspBankInfo.BankInfos[0].CardNumber
			}
			//bankStatus := BankStatus(rspBankInfo.BankType)
			//获取员工学历
			rspEdu, _ := model.StaffServer.GetEduList(ctx, &gpb.StaffEdu{
				Hid: v.BaseRes.Id,
			})
			//开户银行类型
			var eduStatus, schoolName, eduInat, maJor, eduEndAt string

			if len(rspEdu.StaffEduList) > 0 {
				eduStatus = EduStatus(rspEdu.StaffEduList[0].Education)
				schoolName = rspEdu.StaffEduList[0].SchoolName
				eduInat = TimeToStringEx(rspEdu.StaffEduList[0].InAt)
				maJor = rspEdu.StaffEduList[0].Major
				eduEndAt = TimeToStringEx(rspEdu.StaffEduList[0].OutAt)
			}

			//是否首次入职
			Turnover := IsTurnover(v.StaffInOut.Turnover)
			//转正时间
			becomeTime := TimeToStringEx(v.StaffInOut.InAt)
			xlsxNews.SetSheetRow("Sheet1", "A"+strconv.Itoa(lint), &[]interface{}{
				v.BaseRes.WorkId, v.BaseRes.NumberName, v.BaseRes.Name, v.BaseRes.Phone, v.BaseRes.FName,
				v.BaseRes.RoleName, v.BaseRes.WName, employeeState, userInfoState, TimeToStringEx(v.StaffInOut.InAt), TimeToStringEx(v.StaffInOut.LzAt), isCont, typeContra, TimeToStringEx(v.StaffContra.ContAt), isSocial, v.StaffInsura.City, TimeToStringEx(v.StaffInsura.At), v.StaffInOut.PinUName, sexTitle, TimeToStringEx(v.BaseRes.Birthday), regAddress, v.BaseRes.HujiAddress, v.BaseRes.NowAddress, v.BaseRes.Email, Marriage, v.BaseRes.NumberId, v.BaseRes.UrgentName, v.BaseRes.UrgentPhone, bankStatus, bankInfo, cardNumber, eduStatus, schoolName, eduInat, maJor, v.BaseRes.City, v.StaffInOut.JianUName, Turnover, becomeTime, eduEndAt, v.BaseRes.UpNote,
			})
			lint++
		}
	}
	filepath = util.ExePathJoin(fmt.Sprintf("upload/%d_%s", time.Now().Unix(), "_staff.csv"))
	_ = xlsxNews.SaveAs(filepath)
	defer os.Remove(filepath)
	return htp.RespFile(c, filepath)
}

//员工状态 1 入职未转正，2 入职已转正，3 离职  1 默认，2 男，3 女
func EmployeeStatus(t int64, j int32) (string, string) {
	var TName, Sex string
	switch t {
	case 1:
		TName = "在职"
	case 2:
		TName = "在职"
	case 3:
		TName = "离职"
	default:
		TName = "未知"
	}

	switch j {
	case 1:
		Sex = "默认"
	case 2:
		Sex = "男"
	case 3:
		Sex = "女"
	default:
		Sex = "未知"
	}
	return TName, Sex
}

//员工状态 1 入职未转正，2 入职已转正，3 离职  1 默认，2 男，3 女
func EmployeeInfoStatus(t int64) string {
	var TName string

	switch t {
	case 1:
		TName = "试用"
	case 2:
		TName = "转正"
	default:
		TName = "--"
	}

	return TName
}

//合同是否签署 1，未签署 2.已签署  1: 电子 2:纸质
func ContraStatus(t, i int64) (string, string) {
	var TName, IName string
	switch t {
	case 1:
		TName = "未签署"
	case 2:
		TName = "已签署"
	default:
		TName = "未知"
	}
	switch i {
	case 1:
		TName = "电子"
	case 2:
		TName = "纸质"
	default:
		TName = "未知"
	}
	return TName, IName
}

//是否已交社保  1，未签署 2.已签署
func SocialStatus(t int64) string {
	var TName string
	switch t {
	case 1:
		TName = "未签署"
	case 2:
		TName = "已签署"
	default:
		TName = "未知"
	}
	return TName
}

//是否首次入职
func IsTurnover(t int64) string {
	var TName string
	if t > 1 {
		TName = "不是"
	} else {
		TName = "是"
	}
	return TName
}

//开户银行信息  1: 工商，2 建设，3 农业
func BankStatus(t int64) string {
	var TName string
	switch t {
	case 1:
		TName = "工商"
	case 2:
		TName = "建设"
	case 3:
		TName = "农业"
	default:
		TName = "未知"
	}
	return TName
}

//学历信息 1: 工商，2 建设，3 农业
func EduStatus(t int64) string {
	var TName string
	switch t {
	case 1:
		TName = "初中及以下"
	case 2:
		TName = "中专"
	case 3:
		TName = "大专"
	case 4:
		TName = "本科"
	case 5:
		TName = "研究生"
	default:
		TName = "未知"
	}
	return TName
}

//户籍类型 1 默认，2 农业户籍，3 非农业户籍   0 默认， 1 未婚，2 已婚
func RegAdderss(t, j int32) (string, string) {
	var TName, Marriage string
	switch t {
	case 1:
		TName = "默认，2"
	case 2:
		TName = "农业户籍"
	case 3:
		TName = "非农业户籍"
	default:
		TName = "未知"
	}
	switch j {
	case 0:
		Marriage = "默认"
	case 1:
		Marriage = "未婚"
	case 2:
		Marriage = "已婚"
	default:
		Marriage = "未知"
	}
	return TName, Marriage
}

/*
 * 描述: 时间戳转格式化为字符串
 *
 ***************************************************************************/
func TimeToStringEx(nTimer int64) string {
	if nTimer <= 0 {
		return "-"
	}
	tm := time.Unix(nTimer, 0)
	return tm.Format("2006-01-02 15:04:05")
}
